package com.it.jpa.controller;

import com.it.jpa.domain.Contract;
import com.it.jpa.model.ApiModel;
import com.it.jpa.service.ContractService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.*;

/**
 * @Author LHN
 * @ClassName ContractController
 * @Date 2021/10/23
 * @Description }
 */
@RestController
public class ContractController {
    @Autowired
    ContractService contractService;

    @GetMapping("/insert")
    public ApiModel insert(){
        Contract contract = new Contract("10086",true,"商业合同",111000,0.5F,true,"阿斯顿","1008611","2021-10-23 16:25:09","2021-10-23 16:25:20","");
        return contractService.insert(contract);
    }

    @GetMapping("/updateById")
    public ApiModel updateById(Integer id){
        return contractService.updateById("sam1132",id);
    }

    @GetMapping("/deleteById")
    public ApiModel deleteById(String id){
       return contractService.deleteById(Integer.parseInt(id));
    }

    @GetMapping("/findAll")
    public ApiModel findAll(){
        return contractService.findAll();
    }

    @GetMapping("/findByCondition")
    public ApiModel findByCondition(String contractNo,String contractType,String contactName){
        return contractService.findByCondition(contractNo, contractType, contactName);
    }

    @GetMapping("/findByContractStatus")
    public ApiModel findByContractStatus(Boolean contractStatus){
        return contractService.findByContractStatus(contractStatus);
    }

    @GetMapping("/findByPage")
    public ApiModel findByPage(Integer page, Integer pageSize, String contractNo){
        return contractService.findByPage(page,pageSize,contractNo);
    }
}
